package com.richest.api.send;

import java.util.List;

import com.richest.api.utils.HttpUtil;
import com.richest.api.utils.PublicUtil;
import com.richest.bean.ReplyBean;
import com.richest.bean.SendStateBean;

public class DataApi {
	private static String sDataUrl = "http://smsapi.c123.cn/DataPlatform/DataApi";
	private static String sAccount = "";
	private static String sAuthKey = "";

	public DataApi() {
	}

	public static void initialzeAccount(String url, String account, String authkey) {
		sDataUrl = url;
		sAccount = account;
		sAuthKey = authkey;
	}

	public static String querySendState() throws Exception {
		StringBuilder sb = new StringBuilder();
		sb.append("action=getSendState&ac=");
		sb.append(sAccount);
		sb.append("&authkey=");
		sb.append(sAuthKey);
		return HttpUtil.post(sDataUrl, sb.toString(), "GET", "UTF-8");
	}

	public static String queryReply() throws Exception {
		StringBuilder sb = new StringBuilder();
		sb.append("action=getReply&ac=");
		sb.append(sAccount);
		sb.append("&authkey=");
		sb.append(sAuthKey);
		return HttpUtil.post(sDataUrl, sb.toString(), "GET", "UTF-8");
	}

	public static List<SendStateBean> getSendState() {
		try {
			String sRet = querySendState();
			return PublicUtil.parseSendState(sRet);
		} catch (Exception var1) {
			return null;
		}
	}

	public static List<ReplyBean> getReply() {
		try {
			String sRet = queryReply();
			return PublicUtil.parseReply(sRet);
		} catch (Exception var1) {
			return null;
		}
	}
}
